package com.ruoyi.caipiao.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author wangcen
 * @date 2025/1/3 21:44
 */
@Slf4j
public class Pl3Test5 {

    public static void main(String[] args) {
//        String today = DateUtil.format(new Date(), "yyyy-MM-dd");
        String today ="2025010511";
        cal(today);
    }

    public static void cal(String today) {
        log.info("计算开始");

//        String today = DateUtil.format(new Date(), "yyyy-MM-dd");
        String dir = "D:\\pl3\\" + today;
        Set<String> set = new TreeSet<>();
        File file = new File(dir);
        File[] files = file.listFiles();
        for (File file1 : files) {
            List<String> strings = MyFileUtil.readFileAsList(file1);
            int maxCt = 0;
            String maxCtCode = "";
            for (String str : strings) {
                String[] split = str.split(",");
                int ct = Integer.parseInt(split[1]);
                if(ct > maxCt) {
                    maxCtCode = split[0];
                    maxCt = ct;
                }
            }

            MyFileUtil.writeContentToFile(dir + File.separator + "0000000_max_count_nums.txt", maxCtCode + "," + maxCt + "\r\n", true);
            set.add(maxCtCode);
        }
        log.info("排除号码("+set.size()+"):"+set.toString());
        MyFileUtil.writeContentToFile(dir + File.separator + "0000000_max_count_nums.txt", "排除号码("+set.size()+"):"+set.toString(), true);
        log.info("计算完成");

    }
}
